# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=haskell-line2pdf
pkgver=0.0.7
pkgrel=3
pkgdesc='Simple command-line utility to convert text into PDF.'
arch=('x86_64' 'aarch64')
url='http://hackage.haskell.org/package/line2pdf'
license=('GPL')
makedepends=('ghc')
depends=('haskell-regex-compat' 'haskell-mtl')
install='haskell-line2pdf.install'
source=("http://hackage.haskell.org/packages/archive/line2pdf/$pkgver/line2pdf-$pkgver.tar.gz")
sha512sums=('3ffeee768fc31ea23ed14cd082fc54997c1c9790203a68939b686fbf34e944e6c5ab525de52fda3aab22af2bbe8577c27262b48b082cc2d3dfe322a21f541be2')
options=('staticlibs')

build() {
  cd "line2pdf-$pkgver"

  runhaskell Setup configure -O -p --enable-split-objs --enable-shared \
    --prefix=/usr --docdir="/usr/share/doc/$pkgname" \
    --libsubdir=\$compiler/site-local/\$pkgid
  runhaskell Setup build
  runhaskell Setup haddock
  runhaskell Setup register   --gen-script
  runhaskell Setup unregister --gen-script
  sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

package() {
  cd "line2pdf-$pkgver"

  install -Dm 744 register.sh "$pkgdir/usr/share/haskell/$pkgname/register.sh"
  install -m 744 unregister.sh \
    "$pkgdir/usr/share/haskell/$pkgname/unregister.sh"
  install -dm 755 "$pkgdir/usr/share/doc/ghc/html/libraries"
  ln -s "/usr/share/doc/$pkgname/html" \
    "$pkgdir/usr/share/doc/ghc/html/libraries/line2pdf"
  runhaskell Setup copy --destdir="$pkgdir"
}

